<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>新生报到注册管理员管理后台系统</title>
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <el-menu
                :default-active="activeIndex2"
                class="el-menu-demo"
                mode="horizontal"
                @select="handleSelect"
                background-color="#379ae0"
                text-color="#fff"
                active-text-color="#e4a61e">
            <el-menu-item index="1"><a href="AdminIndex.html">学生管理中心</a></el-menu-item>
            <el-menu-item index="3" ><a href="">消息管理中心</a></el-menu-item>
            <el-menu-item index="3" ><a href="AdminStu_inSchool.html">到校统计</a></el-menu-item>
        </el-menu>
    </div>
    <div class="app-container">
        <div class="box">
            <!--查询条件-->
            <div class="filter-container">
                <el-input placeholder="学生学号" v-model="pagination.stuId" style="width: 200px;" class="filter-item"></el-input>
                <el-input placeholder="学生姓名" v-model="pagination.stuName" style="width: 100px;" class="filter-item"></el-input>
                <el-select v-model="pagination.thistype" style="width: 100px;"   placeholder="问题类型">
                    <el-option label="寝室问题" :value="1">寝室问题</el-option>
                    <el-option label="签到问题" :value="2">签到问题</el-option>
                    <el-option label="系统问题" :value="3">系统问题</el-option>
                    <el-option label="其他问题" :value="4">其他问题</el-option>
                    <el-option :value="null">取消选择</el-option>
                </el-select>
                <!--在条件查询时初始化currentPage的值为1-->
                <el-button @click="pagination.currentPage=1;findPage()" class="dalfBut">执行查询</el-button>
            </div>
            <!--列表展示-->
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column prop="id" align="center" width="60" label="序号"></el-table-column>
                <el-table-column prop="stuId" label="学号" width="100"  align="center"></el-table-column>
                <el-table-column prop="stuName" label="姓名" width="80" align="center"></el-table-column>
                <el-table-column prop="createTime" label="时间" width="150" align="center"></el-table-column>
                <el-table-column prop="thistype" label="类型" width="100" align="center"></el-table-column>
                <el-table-column prop="infomessage" label="留言信息" width="900" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="lookMessageInfo(scope.row)">查看详情</el-button>
                        <el-button size="mini" type="danger" @click="handleDelete(scope.row)">已解决</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!--分页标签-->
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
            <!--查看问题详情弹层 -->
            <div class="add-form">
                <el-dialog title="查看问题详情" :visible.sync="dialogFormVisible4Edit">
                    <el-form ref="dataEditForm" :model="formData" :rules="rules" label-position="right" label-width="100px">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="学号" prop="stuId">
                                    <el-input v-model="formData.stuId"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="姓名" prop="stuName">
                                    <el-input v-model="formData.stuName"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="时间" prop="thisTime">
                                    <el-input v-model="formData.thisTime"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="类型" prop="thisType">
                                    <el-input v-model="formData.thisType"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="电话" prop="phoneNumber">
                                    <el-input v-model="formData.phoneNumber"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="邮箱" prop="thisEmail">
                                    <el-input v-model="formData.thisEmail"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="问题详情" prop="thisInfo">
                                    <el-input  type="textarea" :rows="3" v-model="formData.thisInfo"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">关闭</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    var vue = new Vue({
        el: '#app',
        data:{
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize:10,//每页显示的记录数
                total:0,//总记录数
                queryString:null//查询条件
            },
            dataList: [],//当前页要展示的分页列表数据
            formData: {},//表单数据
            dialogFormVisible4Edit:false,//编辑表单是否可见
        },
        //钩子函数，VUE对象初始化完成后自动执行
        created() {
            this.loginOK();
            this.findPage();
        },
        methods: {
            loginOK(){
                var id = sessionStorage.getItem("adminId");
                if(id==null || id==""){
                    console.log("你没有登录");
                    location.href="adminlogin.html";
                    axios.get("/loginfalse/admin").then(()=>{})
                }
            },
            //前端boolean类型的值的显示
            formatBoolean: function (row, column, cellValue) {
                var ret = ''  //你想在页面展示的值
                if (cellValue) {
                    ret = "已领取"  //根据自己的需求设定
                } else {
                    ret = "未领取"
                }
                return ret;
            },
            //分页查询
            findPage() {
                var param ={
                    //当前页
                    currentPage:this.pagination.currentPage,
                    //分页数
                    pageSize:this.pagination.pageSize,
                    //学号
                    stuId:this.pagination.stuId,
                    //学生姓名
                    stuName:this.pagination.stuName,
                    //类型
                    thistype:this.pagination.thistype,
                };
                axios.post("/message/findPage",param).then((res)=>{
                    this.pagination.total = res.data.total;
                    this.dataList = res.data.rows;
                })
            },
            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.findPage();
            },
            handleCreate2(){
                this.dialogFormVisible4Edit = true;
                this.resetForm();
            },
            // 消息详情窗口
            lookMessageInfo(row) {
                this.dialogFormVisible4Edit = true;
                axios.get("/message/findById?id="+row.id).then((res)=>{
                    if(res.data.flag){
                        this.formData = res.data.data;
                    }else{
                        this.$message.error(res.data.message);
                    }
                });
            },
            // 删除
            handleDelete(row) {
                this.$confirm("你确定该问题已解决吗，该步骤会删除这条数据","提示",{type:'warning'}).then(()=>{
                    axios.get("/message/remove?id=" +row.id).then((res)=>{
                        if(res.data.flag){
                            this.$message({
                                type:'success',
                                message:res.data.message
                            });
                            this.findPage();
                        }else{
                            this.$message.error(res.data.message)
                        }
                    });
                }).catch(()=>{
                    this.$message({
                        type:'info',
                        message:'操作已取消'
                    });
                });
            }
        }
    })
</script>
</html>